x86: fix errors arising from c/s dab76ff
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 15 Feb 2016 13:12:54 +0000 (14:12 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 15 Feb 2016 13:12:54 +0000 (14:12 +0100)
commitfb0e5fea8acaf55d313a6eb6037c6549d0fc10af
tree60e2ec8d3c885e7233f3abba8ea5aa01f810a4be
parent0359b365c6aaf1303244b064acc84c493cc0e730
x86: fix errors arising from c/s dab76ff

Coverity correctly identifies that the changes in mtrr_attrib_to_str()
introduce dead code.  strings[] is a 2d array, rather than an array of
strings, which means that strings[x] will never be a NULL pointer.

Adjust the check to compenstate, by looking for a NUL in strings[x][0]
instead.

Curiously, Coverity did not notice the same error with memory_type_to_str().
There was also a further error; the strings were not NULL terminated, which
made the return type of memory_type_to_str() erronious.

Bump the 2D array to 3 characters, so the strings retain their NUL characters,
and introduce an ASSERT() as requested on one thread of the original patch.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/cpu/mtrr/generic.c
xen/arch/x86/mm/p2m-ept.c